import 'package:get/get.dart';

import '../../../bean/bean_train.dart';
import '../../../net/dio_utils.dart';
import '../model/train_model.dart';

class TeacherTrainDetailsController extends GetxController with TrainModel {
  int trainId;

  TeacherTrainDetailsController({this.trainId});

  TrainBean _trainBean;
  bool _isLoading = true;

  bool getIsLoading() {
    return _isLoading;
  }

  TrainBean getTrainBean() {
    return _trainBean;
  }

  requestDetailsFunction({bool click = false}) async {
    _isLoading = true;
    if (click) {
      update(["root"]);
    }
    _trainBean = await getTrainNetDatils(trainId: trainId);
    _isLoading = false;
    update(["root"]);
  }

  bool _isUpdateLoading = false;

  bool getIsUpdateLoading() {
    return _isUpdateLoading;
  }

  CourseAndTeacherBean _courseAndTeacherBean;

  CourseAndTeacherBean getUpdateDetails() {
    return _courseAndTeacherBean;
  }

  updateCourseCodeRequest(
      {bool click = false, int id, int teacherSignRecoderId}) async {
    _isUpdateLoading = true;
    if (click) {
      update(["$id"]);
    }
    Map<String, dynamic> monthMap = {
      "id": teacherSignRecoderId,
    };
    ResponseInfo statisRresponseInfo = await DioUtils.instance
        .postRequest(url: HttpHelper.updateCourseCode, jsonMap: monthMap);
    if (statisRresponseInfo.success) {
      _courseAndTeacherBean =
          CourseAndTeacherBean.fromJson(statisRresponseInfo.data);
    } else {
      _courseAndTeacherBean = null;
    }
    _isUpdateLoading = false;
    update(["$id"]);
  }
}
